$(function () {
    var columns = [
        {
            field: 'tableName',
            title: '表名称'
        },
        {
            field: 'comment',
            title: '注释信息'
        },
        {
            field: 'createTime',
            title: '创建时间',
            formatter: function (value, row, index) {
                return changeDateFormat("yyyy-MM-dd hh:mm:ss", new Date(value))
            }
        }, {
            field: 'tableName',
            title: '操作',
            formatter: function (value, row, index) {
                return '<button id="btn_edit" type="button" class="btn btn-primary  btn-xs" onclick="generator(\'' + value + '\')"><i class="fa fa-edit"></i> 生成代码</button>';
            }
        }
    ]
    createBootstrapTable($("#table"), '/sys/code/info', columns, false, null, 'client')
})


function generator(val) {
    var data = {
        tableName:val
    }
    request('/sys/code/generator', 0, data, function (res) {
        if (res.code == '0') {
            layer.msg(res.msg, {time: 1000}, function () {
                onLoads($("#href").val())
            })
        }else {
            layer.msg(res.msg, {time: 1000,icon:5})
        }
    }, function (error) {
        layer.msg("系统异常！")
    })
}